package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YhFilling;
import com.ruoyi.system.service.IYhFillingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 充装信息Controller
 * 
 * @author yinhe
 * @date 2022-11-07
 */
@RestController
@RequestMapping("/system/filling")
public class YhFillingController extends BaseController
{
    @Autowired
    private IYhFillingService yhFillingService;

    /**
     * 查询充装信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:filling:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhFilling yhFilling)
    {
        startPage();
        List<YhFilling> list = yhFillingService.selectYhFillingList(yhFilling);
        return getDataTable(list);
    }

    /**
     * 导出充装信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:filling:export')")
    @Log(title = "充装信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhFilling yhFilling)
    {
        List<YhFilling> list = yhFillingService.selectYhFillingList(yhFilling);
        ExcelUtil<YhFilling> util = new ExcelUtil<YhFilling>(YhFilling.class);
        util.exportExcel(response, list, "充装信息数据");
    }

    /**
     * 获取充装信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:filling:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhFillingService.selectYhFillingById(id));
    }

    /**
     * 新增充装信息
     */
    @PreAuthorize("@ss.hasPermi('system:filling:add')")
    @Log(title = "充装信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhFilling yhFilling)
    {
        return toAjax(yhFillingService.insertYhFilling(yhFilling));
    }

    /**
     * 修改充装信息
     */
    @PreAuthorize("@ss.hasPermi('system:filling:edit')")
    @Log(title = "充装信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhFilling yhFilling)
    {
        return toAjax(yhFillingService.updateYhFilling(yhFilling));
    }

    /**
     * 删除充装信息
     */
    @PreAuthorize("@ss.hasPermi('system:filling:remove')")
    @Log(title = "充装信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhFillingService.deleteYhFillingByIds(ids));
    }
}
